package com.example.caoh.service.impl.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.caoh.entity.SysUser;
import com.example.caoh.mapper.SysUserMapper;
import com.example.caoh.service.impl.BaseService;
import com.example.caoh.service.sys.SysUserService;
import com.google.common.base.Strings;

import tk.mybatis.mapper.entity.Example;

@Service("userService")
public class SysUserServiceImpl extends BaseService<SysUser> implements SysUserService {
	
	@Autowired
	private SysUserMapper sysUserMapper;

	public boolean isExit(SysUser o) {
		boolean flag = false;
		Example example = new Example(SysUser.class);
		Example.Criteria criteria = example.createCriteria();
		if (!Strings.isNullOrEmpty(o.getUsername())) {
			criteria.andEqualTo("username", o.getUsername());
		}
		List<SysUser> list = selectByExample(example);
		if (list.size() > 0) {
			flag = true;
		}
		return flag;

	}

	@Override
	public SysUser selectByLongName(String username) {
		// TODO Auto-generated method stub
		return sysUserMapper.selectByLongName(username);
	}
}
